package com.stox.services.charting.repository;

import com.stox.services.core.repository.AbstractCachingFileRepository;
import com.stox.shared.charting.model.ChartGroup;

public class ChartGroupFileRepository extends AbstractCachingFileRepository<ChartGroup> {

	public static final ChartGroupFileRepository INSTANCE = new ChartGroupFileRepository();
	
	private ChartGroupFileRepository() {
		super("chart-group");
	}

	@Override
	public ChartGroup deserialize(String text) {
		ChartGroup chartGroup = new ChartGroup();
		String[] tokens = text.split(",");
		chartGroup.setId(Long.parseLong(tokens[0]));
		chartGroup.setName(tokens[1]);
		return chartGroup;
	}

	@Override
	public String serialize(ChartGroup chartGroup) {
		return chartGroup.getId()+","+chartGroup.getName();
	}

}
